package gererg;

/**
 * @author leon(liangzou0318@gmail.com)
 * @date 2012-12-12
 * @filaname ThreadWait.java
 */
public class ThreadWait {
	private Integer flag=0;
   public class Thread1 extends Thread{
	   public void run(){
		   for(int i=0;i<2;i++){
			   System.out.println("aaa");
			    flag=1;
				flag.notify();		
		   }
	   }
   }
   public class Thread2 extends Thread{
	   public void run(){
		   for(int i=0;i<2;i++){
			   System.out.println("bbb");
			   try {
				flag.wait();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		   }
	   }
   }
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		ThreadWait tw=new ThreadWait();
		Thread1 t1=tw.new Thread1();
		Thread2 t2=tw.new Thread2();
		t2.start();
		t1.start();
	}

}
